package com.es.designmode.mediator;

/**
 * 具体中介者类，可以拥有两个同事的信息
 */
public class ConcreteMediator extends Mediator {

    private ConcreteColleague1 colleague1;
    private ConcreteColleague2 colleague2;

    public ConcreteColleague1 getColleague1() {
        return colleague1;
    }

    public void setColleague1(ConcreteColleague1 colleague1) {
        this.colleague1 = colleague1;
    }

    public ConcreteColleague2 getColleague2() {
        return colleague2;
    }

    public void setColleague2(ConcreteColleague2 colleague2) {
        this.colleague2 = colleague2;
    }

    /**
     * 根据对象做不选择判断，通知对象
     * 重写发送信息的方法
     *
     * @param message
     * @param colleague
     */
    @Override
    public void send(String message, Colleague colleague) {
        if (colleague.equals(colleague1)) {
            colleague2.notifyy(message);
        } else {
            colleague1.notifyy(message);
        }
    }
}
